package com.paradox.aggregation.auth.controller;

import io.jsonwebtoken.Jwts;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;

@RestController
@RequestMapping("/resource")
public class ResourceController {

    @GetMapping("/getResource")
    public Object getResource(HttpServletRequest request){
        String header = request.getHeader("Authorization");
        String token = header.substring(header.indexOf("bearer") + 7);
        return Jwts.parser().setSigningKey("12345".getBytes(StandardCharsets.UTF_8)).parseClaimsJws(token).getBody();
        //return "resource";
    }
}
